03. Checking the build.gradle file

Checking the build.gradle file

When importing someone else's code into Android Studio, you should normally use the same package versions and target SDK settings that the original code was designed to use. Keeping your own projects up to date is always a good practice, though.

Since Android is always releasing new sums of SDK packages, whenever you open or import an old project in Android Studio, you may see an alert saying that the plugin is too old:

Android Studio will warn you if you import a project whose gradle version is too old

Android Studio will warn you if you import a project whose gradle version is too old

To resolve this, click on the hyperlink "Fix Gradle version (as part of the update, the Android plugin will be updated to version 2.3.3) Open Documentation" which opens up the documentation with instructions on how to resolve the issue.

Alternatively, you can update the Gradle version directly by navigating to Gradle Scripts, double-clicking the build.gradle file to open and edit the file:

Make sure you include the most up-to-date versions of:

  • compileSdkVersion
  • buildToolsVersion
  • targetSdkVersion

In addition, in the same file, check if all the dependencies are also updated, for example when the beta version of Constraint Layout beta was released, she would complain about this from an alpha version, since it is now obsolete:

Generally, Android Studio would highlight any outdated packages, such as: